<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="content-type" content="text/html; charset=utf-8">
    <meta name="renderer" content="webkit"/>
    <meta name="force-rendering" content="webkit"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="stylesheet" href="../css/shop.css">
    <link rel="stylesheet" href="../css/weui.min.css">

    <style>

    </style>
</head>

<body>
<div class="withdrawal-header">
    <div class="header" style="display: flex">
        <div class="haader-left" href="javascript:window.history.go(-1)">
        </div>
        <div class="haader-content">收款账单</div>
        <div class="haader-right">
            <i class="iconfont icon-riqi"></i>
        </div>
    </div>
    <div class="withdrawal-money">0.00</div>
    <div class="withdrawal-balance">月收款总计(元)</div>
</div>
<div class="collection-list" id="moneyList">


</div>
<link rel="stylesheet" href="../css/weui.min.css">
<link rel="stylesheet" href="../css/jquery-weui.min.css">
<script src="../js/jquery-2.1.4.js"></script>
<script src="../js/jquery-weui.js"></script>
<script src="../wxJs/utils/contain.js"></script>
<script src="../wxJs/utils/storage.js"></script>

<script>
    $(".icon-riqi").picker({
        onClose: function (obj) {
            var year = parseInt(obj.value[0])
            var month = parseInt(obj.value[1])
            if (month < 10) {
                month = "0" + month
            }
            var selectMonth = year + "-" + month;
            console.log(selectMonth)

            queryMoneyList(selectMonth)
        },
        title: "请选择年月",
        cols: [{
            textAlign: 'center',
            values: (function () {
                var arr = [], cur = new Date();
                for (var i = 2019; i <= cur.getFullYear(); i++) {
                    arr.push(i + "年")
                }
                return arr
            })()
            //如果你希望显示文案和实际值不同，可以在这里加一个: [.....]
        },
            {
                textAlign: 'center',
                values: ["1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月",]
            }
        ]
    });

    var shopId = GetQueryString("shopId");    //当前商家id
    if (!shopId){
        window.history.back(-1);
    }
    $(function () {
        var date = new Date(), y = date.getFullYear(), m = date.getMonth()+1;
        if (m < 10) {
            m = "0" + m
        }
        var nowMonth = y + "-" + m
        /*查询当前月*/
        queryMoneyList(nowMonth)
    })



    function queryMoneyList(myMoth) {
        $.post(getWeiContextPath() + "/wx/order/queryMoneyList", {shopId: shopId,myMoth:myMoth}, function (res) {
            console.log(res)
            var _moneyList = $('#moneyList').empty()
            $.each(res.list, function (i, obj) {
                _moneyList.append('<div class="collection-item">\n' +
                    '            <div>\n' +
                    '                <div class="collection-name">门店收款</div>\n' +
                    '                <div>' + obj.createTime + '</div>\n' +
                    '            </div>\n' +
                    '            <div class="cl-main">+' + obj.shopMoney + '</div>\n' +
                    '        </div>')
            })
            $(".withdrawal-money").text(res.monthMoney)

        })
    }

</script>
</body>

</html>